package com.company.笔试.超过k次的数;

import java.util.HashMap;
import java.util.Scanner;
import java.util.TreeMap;

/**
 * @author ylr
 * @version 1.0.0
 * @ClassName Main.java
 * @Description TODO
 * @createTime 2021年10月21日 21:28:00
 */
public class Main {
    static int res =-1;
    static int index;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        String[] s1 = s.split(" ");
        int n = Integer.valueOf(s1[0]);
        int k = Integer.valueOf(s1[1]);


        String arr = in.nextLine();
        String[] s2 = arr.split(" ");
        TreeMap<String,Integer> map = new TreeMap<>();
        HashMap<String,Integer> mapkey = new HashMap<>();
        int i =0 ;
        for (String ss : s2) {
            if (!mapkey.containsKey(ss)){
                mapkey.put(ss,i);
            }
            String mykey = ss+"-"+mapkey.get(ss);
            if (map.containsKey(mykey)){
                map.put(mykey,map.get(mykey)+1);
            }else {
                map.put(mykey,1);
            }
            i++;
        }

        map.forEach((key,val)->{
            if (val>res){
                res = val;
                String[] indexkey = key.split("-");
                index= Integer.valueOf(indexkey[1]);
            }
        });
        if (res>k) {
            System.out.println(s2[index]);
        }else {
            System.out.println("-1");
        }
    }
}
